package com.tsinjie.metadata.database.model;

import java.io.Serializable;

/**
 * Created by LiuXunming on 2014-07-20.
 * 数据库表字段
 */
public class Column implements Serializable {
    /**
     * 字段名称
     */
    protected String columnName;
    /**
     * 字段类型
     */
    protected int type;
    /**
     * 字段长度
     */
    protected Integer length;
    /**
     * 是否允许空
     */
    protected boolean nullable;
    /**
     * 默认值
     */
    protected Object defaultValue;
    /**
     * 注释
     */
    protected String comment;

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public Integer getLength() {
        return length;
    }

    public void setLength(Integer length) {
        this.length = length;
    }

    public boolean getNullable() {
        return nullable;
    }

    public void setNullable(boolean nullable) {
        this.nullable = nullable;
    }

    public Object getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(Object defaultValue) {
        this.defaultValue = defaultValue;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    @Override
    public String toString() {
        return "Column{" +
                "columnName='" + columnName + '\'' +
                ", type=" + type +
                ", length=" + length +
                ", nullable=" + nullable +
                ", defaultValue=" + defaultValue +
                ", comment='" + comment + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Column)) return false;

        Column column = (Column) o;

        if (columnName != null ? !columnName.equals(column.columnName) : column.columnName != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return columnName != null ? columnName.hashCode() : 0;
    }
}
